# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=insanity
pkgver=117.cf51ff3
pkgrel=3
pkgdesc='Generate Payloads and Control Remote Machines .'
groups=('blackarch' 'blackarch-exploitation')
arch=('any')
url='https://github.com/4w4k3/Insanity-Framework'
license=('BSD')
depends=('python2' 'wget' 'wine')
makedepends=('git')
source=("$pkgname::git+https://github.com/4w4k3/Insanity-Framework.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|/env python|/env python2|' "$pkgname.py"
  sed -i 's|py_ver=get_py_version(),|py_ver="python2.7",|' bin/settings.py
}

package() {
  cd Insanity-Framework

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname/"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md AUTHOR.rd
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm LICENSE README.md AUTHOR.rd

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

